package com.example.patient.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.common.support.Result;
import com.example.common.utils.RequestHelp;
import com.example.patient.dto.req.*;
import com.example.patient.dto.resp.*;
import com.example.patient.service.InquiryService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import java.util.List;

/**
 * @Author wxy
 * @Date 2021/1/18 10:54
 * @Version 1.0
 */
@RestController
@Api(tags = "问诊")
@RequestMapping("/api/Inquiry")
public class InquiryController {
    @Resource
    private InquiryService inquiryService;

    @ApiOperation(value = "问诊列表", notes = "问诊列表")
    @PostMapping(value = "/IMList")
    public Result<List<IMListResp>> IMList() {
        return Result.success(inquiryService.IMList());
    }

    @ApiOperation(value = "未接诊列表", notes = "未接诊列表")
    @PostMapping(value = "/NoReceiveList")
    public Result<List<NoReceiveListResp>> NoReceiveList() {
        return Result.success(inquiryService.NoReceiveList());
    }

    @ApiOperation(value = "问诊、就诊、患者基础信息", notes = "问诊、就诊、患者基础信息")
    @PostMapping(value = "/Patients")
    public Result<PatientsResp> Patients(@RequestBody PatientsReq req) {
        return Result.success(inquiryService.Patients(req));
    }

    @ApiOperation(value = "问诊、就诊、患者基础信息", notes = "问诊、就诊、患者基础信息")
    @PostMapping(value = "/saveTongueImg")
    public Result<Boolean> saveTongueImg(HttpServletRequest request){  
        JSONObject Jo = RequestHelp.GetFromBodyJson(request);
        String OrderNO = Jo.getString("OrderNO");    
        String TongueImg = Jo.getString("TongueImg");
        return Result.success(inquiryService.saveTongueImg(OrderNO, TongueImg));
    }

    @ApiOperation(value = "就诊详情（非本院首诊）", notes = "就诊详情（非本院首诊）")
    @PostMapping(value = "/DiagnosisOut")
    public Result<DiagnosisOutResp> DiagnosisOut(@RequestBody DiagnosisOutReq req) {
        return Result.success(inquiryService.DiagnosisOut(req));
    }

    @ApiOperation(value = "问诊、就诊、对话记录", notes = "问诊、就诊、对话记录")
    @PostMapping(value = "/IMLogList")
    public Result<PageInfo<IMLogListResp>> IMLogList(@RequestBody IMLogListReq req) {
        return Result.success(inquiryService.IMLogList(req));
    }

    @ApiOperation(value = "问诊、就诊、记录对话", notes = "问诊、就诊、记录对话")
    @PostMapping(value = "/IMSave")
    public Result<Boolean> IMSave(@RequestBody IMSaveReq req) {
        return Result.success(inquiryService.IMSave(req));
    }

    @ApiOperation(value = "问诊、就诊、上传对话文件", notes = "问诊、就诊、上传对话文件")
    @PostMapping(value = "/IMUpLoad")
    public Result<Object> IMUpLoad(@RequestParam(value = "file") MultipartFile file) {
        return Result.success(inquiryService.IMUpLoad(file));
    }

    @ApiOperation(value = "问诊、就诊、中药处方信息", notes = "问诊、就诊、中药处方信息")
    @PostMapping(value = "/ZRxDetail")
    public Result<ZRxDetailResp> ZRxDetail(@RequestBody ZRxDetailReq req) {
        return Result.success(inquiryService.ZRxDetail(req));
    }

    @ApiOperation(value = "问诊、就诊、西药处方信息", notes = "问诊、就诊、西药处方信息")
    @PostMapping(value = "/XRxDetail")
    public Result<XRxDetailResp> XRxDetail(@RequestBody XRxDetailReq req) {
        return Result.success(inquiryService.XRxDetail(req));
    }

    @ApiOperation(value = "处方信息结算", notes = "处方信息结算")
    @PostMapping(value = "/RxOrderSettlement")
    public Result<RxOrderSettlementResp> RxOrderSettlement(@RequestBody RxOrderSettlementReq req) {
        return Result.success(inquiryService.RxOrderSettlement(req));
    }

    @ApiOperation(value = "处方确认购买", notes = "处方确认购买")
    @PostMapping(value = "/RxOrderBuy")
    public Result<Object> RxOrderBuy(@RequestBody RxOrderBuyReq req) {
        return Result.success(inquiryService.RxOrderBuy(req));
    }

    @ApiOperation(value = "支付完成", notes = "支付完成")
    @PostMapping(value = "/PayCompletion")
    public Result<InquiryPayCompletionResp> PayCompletion(@RequestBody PayCompletionReq req) {
        return Result.success(inquiryService.PayCompletion(req));
    }

    @ApiOperation(value = "问诊评价信息", notes = "问诊评价信息")
    @PostMapping(value = "/CommentInfo")
    public Result<CommentInfoResp> CommentInfo(@RequestBody CommentInfoReq req) {
        return Result.success(inquiryService.CommentInfo(req));
    }

    @ApiOperation(value = "完成问诊评价", notes = "完成问诊评价")
    @PostMapping(value = "/SubmitComment")
    public Result<Object> SubmitComment(@RequestBody SubmitCommentReq req) {
        return Result.success(inquiryService.SubmitComment(req));
    }
}
